package com.java3_16;

import java.util.*;
import java.util.function.Predicate;

public class java3_16 {
    //    public static void main(String[] args) {
//        Collection<String> coll = new ArrayList<>();
//        coll.add("hello");
//        coll.add("java");
//        coll.add("world");
//        coll.add("love");
//        coll.add("you");
//        coll.add("mom");
//        coll.add("dad");
//        coll.add("noon");
//
//        for(String s : coll){
//            System.out.println(s);
//        }
//
//        System.out.println("------------------------");
//
//        coll.removeIf(new Predicate<String>() {
//            @Override
//            public boolean test(String s) {
//                StringBuilder stringBuilder = new StringBuilder();
//                stringBuilder.append(s);
//                StringBuilder reverse = stringBuilder.reverse();
//                return s.equals(reverse.toString());
//            }
//        });
//
//        Iterator<String> iterator = coll.iterator();
//        while(iterator.hasNext()){
//            System.out.println(iterator.next());
//        }
//
//
//    }
//    public static void main(String[] args) {
////        //创建员工对象
////        Employee e1 = new Employee("zhangsan", 6000, 20);
////        Employee e2 = new Employee("lisi", 7000, 20);
////        Employee e3 = new Employee("wangwu", 6000, 24);
////        Employee e4 = new Employee("zhaoliu", 9000, 33);
////
////
////        Employee[] employees = {e1, e2, e3, e4};
////        Arrays.sort(employees);
////        for (int i = 0; i < employees.length; i++) {
////            Employee employee = employees[i];
////            System.out.println(employee.toString());
////        }
////
////        System.out.println("--------------------------");
////        Comparator<Employee> comparator = new Comparator<>() {
////            @Override
////            public int compare(Employee o1, Employee o2) {
////                if(o1.getAge() != o2.getAge()){
////                    return Integer.compare(o1.getAge(),o2.getAge());
////                }
////                return o1.getName().compareTo(o2.getName());
////
////            }
////        };
////
////        Arrays.sort(employees,comparator);
////        for (Employee e : employees){
////            System.out.println(e.toString());
////        }
////
////    }
//}
    public static void main(String[] args) {
//        Coordinate<String> coordinate = new Coordinate<>("zhangsan","打篮球");
//        System.out.println(coordinate.toString());
//
//        Coordinate<Double> coordinate2 = new Coordinate<>(3.14,15.926);
//        System.out.println(coordinate2.toString());

//        Person<Person> my = new Person<>("zhangsan",new Person("lisi"));
//        System.out.println(my.toString());

//        Demon demon = new Demon("白娘子");
//        Person<Demon> demonPerson = new Person<>("许仙", demon);
//        System.out.println(demonPerson.toString());
        //
        //使用泛型可能是因为填入的数据类型未知
        ArrayList<Integer> arrayInteger = new ArrayList<>();
        arrayInteger.add(11);

        Integer n = arrayInteger.get(0);// 这条代码底层如下：

        //（1）get() 方法的返回值返回的是 Object 类型
        Object object = arrayInteger.get(0);
        //（2）编译器自动插入 Integer 的强制类型转换
        Integer n = (Integer) object;



    }
}